package main

import (
	"context"
	"fmt"
	"log"
	"os/exec"
)

// App struct
type App struct {
	ctx context.Context
}

// NewApp creates a new App application struct
func NewApp() *App {
	return &App{}
}

// startup is called when the app starts. The context is saved
// so we can call the runtime methods
// 创建窗口并即将开始加载前端资源时的回调
func (a *App) startup(ctx context.Context) {
	a.ctx = ctx
}

// 应用程序即将退出时的回调
func (b *App) shutdown(ctx context.Context) {}

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
	return fmt.Sprintf("Hello %s, It's show time!", name)
}

func (a *App) OpenCMD() {
	cmd := exec.Command("cmd", "/c", "start", "cmd.exe")

	err := cmd.Run()

	if err != nil {
		log.Fatalf("启动命令行失败: %v", err)
	}

	fmt.Println("新的 CMD 窗口已成功启动！")
}
